<template>
	<view class="body">
		
		<view class="content" v-for="(item,index) in list" :key="index" >
			<view class="title" >{{item.send_time}}</view>
			<view class="detail">
				<view class="detail-tit" >{{item.title}}</view>
				<view v-if="item.thumb" >
					<image :src="item.thumb" ></image>
				</view>
				
				<view class="detail-content" v-html="item.content" ></view>
				
				<!-- <view class="detail-btn">
					<view>查看详情</view>
					<u-icon name="arrow-right" color='#666' size='30' ></u-icon>
				</view> -->
			</view>
		</view>
		
		<u-loadmore v-if="list.length > 0" :status="status" @loadmore="loadmore" />
		
		<u-empty class="noView"  v-if="list.length == 0" mode="message"></u-empty>
		
		<!-- 占位用的 -->
		<view v-if="!list.length" style="height: 80px;" ></view>
		
	</view>
</template>

<script>
	
	export default{
		data(){
			return{
				list: [],
				page: 1,
				lastPage: 1,
				status: 'loadmore',
			}
		},
		onLoad() {
			
			this.getList()
		},
		methods:{
			getList(){
				
				if(this.status == 'nomore' || this.status == 'loading'){
					return
				}
				this.status = 'loading'
				
				this.$https.Index.getMsgList(this.page).then(req => {
				
					this.list = this.list.concat(req.data)
					this.lastPage = req.last_page
					this.page++
					
					this.status = this.page > this.lastPage ? 'nomore' : 'loadmore'
				})
			},
			
			getDetail(){
				this.$https.Index.getMsgDetail(9).then(req => {
					console.log('获取信息详情',req)
				})
			},
			loadmore(){  //下拉加载更多
				this.getList()
			}
		}
	}
	
</script>

<style lang="scss" >
	
	page,.body{
		
		width: 100%;
		height: 100%;
		
		background-color: rgb(250,250,250);
	}
	
	.content{
		margin: 20rpx 0;
		
		.title{
			
			margin: 20rpx 0;
			
			font-size: $uni-font-size-base;
			color: #666;
			text-align: center;
		}
		
		.detail{
			margin: 0 20rpx;
			padding: 20rpx;
			
			border-radius: 10rpx;
			background-color: #FFFFFF;
			
			.detail-tit{
				margin: 16rpx 10rpx 30rpx;
				color: #333333;
				font-size: $uni-font-size-lg;
			}
			
			image{
				
				height: 280rpx;
				width: 100%;
				
				border-radius: 8rpx;
			}
			
			.detail-content{
				margin: 10rpx 0 20rpx;
				color: #666;
			}
			
			.detail-btn{
				display: flex;
				justify-content: space-between;
				
				padding: 24rpx 0 0;
				
				border-top: 1rpx solid rgb(250,250,250);
				
				color: #666;
				font-size: $uni-font-size-base;
			}
		}
	}
	
	.noView{
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
	}
</style>
